import { Module } from '@nestjs/common'
import { APP_GUARD } from '@nestjs/core'
import { JwtModule } from '@nestjs/jwt'
import { AuthService } from './auth.service'
import { UserModule } from '../user/user.module'
import { jwtConstants } from './constants'
// import { JwtStrategy } from './jwt.strategy'
import { AuthController } from './auth.controller'
import { AuthGuard } from './auth.guard'
// import { PermissionModule } from '../permission/permission.module'

@Module({
  imports: [
    UserModule,
    // PermissionModule,
    JwtModule.register({
      // global: true,
      secret: jwtConstants.secret,
      // signOptions: { expiresIn: '3600s' },
    }),
  ], // 导入其他模块
  providers: [
    AuthService,
    {
      provide: APP_GUARD,
      useClass: AuthGuard, // 这里使用 JwtStrategy 作为守卫
    },
    // JwtStrategy,
  ],
  controllers: [AuthController],
  // exports: [AuthService],
})
export class AuthModule {}
